/********************************************************************************************************
 * @file	software_pa.h
 *
 * @brief	This is the header file for B91
 *
 * @author	BLE Group
 * @date	2020
 *
 * @par     Copyright (c) 2020, Telink Semiconductor (Shanghai) Co., Ltd. ("TELINK")
 *          All rights reserved.
 *
 *          Redistribution and use in source and binary forms, with or without
 *          modification, are permitted provided that the following conditions are met:
 *
 *              1. Redistributions of source code must retain the above copyright
 *              notice, this list of conditions and the following disclaimer.
 *
 *              2. Unless for usage inside a TELINK integrated circuit, redistributions
 *              in binary form must reproduce the above copyright notice, this list of
 *              conditions and the following disclaimer in the documentation and/or other
 *              materials provided with the distribution.
 *
 *              3. Neither the name of TELINK, nor the names of its contributors may be
 *              used to endorse or promote products derived from this software without
 *              specific prior written permission.
 *
 *              4. This software, with or without modification, must only be used with a
 *              TELINK integrated circuit. All other usages are subject to written permission
 *              from TELINK and different commercial license may apply.
 *
 *              5. Licensee shall be solely responsible for any claim to the extent arising out of or
 *              relating to such deletion(s), modification(s) or alteration(s).
 *
 *          THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 *          ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 *          WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 *          DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDER BE LIABLE FOR ANY
 *          DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 *          (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 *          LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 *          ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 *          (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 *          SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 *******************************************************************************************************/

#ifndef BLT_PTA_H_
#define BLT_PTA_H_


/**
 *  @brief  pta config
 */

/***********PTA model selecttick = clock_time();***********/
#define 	PTA_NONE				 			0
#define 	PTA_2WIRE							1
#define 	PTA_3WIRE				 			2

#ifndef 	PTA_MODE
#define 	PTA_MODE				 			PTA_3WIRE
#endif

#if (MCU_CORE_TYPE == MCU_CORE_9518)
//not process

#elif (MCU_CORE_TYPE == MCU_CORE_827x)
 /***********PTA IO config***********/
#if (PTA_MODE == PTA_2WIRE)
#define 	BLE_PRIORITY_PIN					PTA_BLE_PRIORITY_PB3
#define     WLAN_ACTIVE_PIN                     GPIO_PB4
#elif (PTA_MODE == PTA_3WIRE)

#define		BLE_ACTIVE_PIN						PTA_BLE_ACTIVE_PB3
#define		BLE_STATUS_PIN						PTA_BLE_STATUS_PB4
#define 	WLAN_DENY_PIN						PTA_WLAN_DENY_PB5

#endif



/************Check the time***********/
#define     PTA_CHECK_TIME_US       			 10
#define 	PTA_BLE_PRIORITY_TIME_US_H     	     5  /*PTA_BLE_PRIORITY_TIME_US <= PTA_CHECK_TIME_US*/
#define 	PTA_BLE_PRIORITY_TIME_US_L           1
#if 	(PTA_CHECK_TIME_US < PTA_BLE_PRIORITY_TIME_US)
			#error "(PTA)Error adding data"
#endif

#endif//#if (PTA_MODE == PTA_2WIRE)

#define rf_get_pta_t1_time()                     (read_reg8(0xf12)+1)

#define         PTA_HIGH_PRI                                 1
#define         PTA_LOW_PRI                                  0

#define         PTA_MANAUL_3W_START                          1
#define         PTA_MANAUL_3W_POST                           0

#define			PTA_STATE_APP				        0x0000000001
#define			PTA_STATE_CONNECT				    0x0000000002
#define			PTA_STATE_CONNECT_UPDATE			0x0000000004
#define			PTA_STATE_MAP_UPDATE				0x0000000008
#define			PTA_STATE_PHY_UPDATE				0x0000000010
#define			PTA_STATE_FIFO_DATA				    0x0000000040


typedef unsigned char (*rf_pta_callback_t)(unsigned int state);

extern rf_pta_callback_t blc_rf_pta_3wireSetPri_cb;

extern rf_pta_callback_t blc_rf_pta_3wireTx2Rx_cb;

extern rf_pta_callback_t    blc_rf_pta_2wire_cb;
/**
 * @brief		Resolve a situation where a "tx2rx" cannot exit
 * @param[in]	ble_ptc_wire_tx2rx_Callback
 * @return      none
 */
void blc_pta_wireTx2RxCallback(rf_pta_callback_t  cb);
/**
 * @brief		pta Callback
 * @param[in]	rf_pta_callback_t
 * @return      none
 */
void blc_pta_wireCallback(rf_pta_callback_t  cb);
/**
 * @brief   	init(IO configuration, in the macro definition)
 * @param[in]   none
 * @return  	none
 */
void rf_pta_init(void);



#endif /* BLT_PTA_H_ */
